<?php
class District_infos extends Public_Controller
{
	function __construct()
	{
		parent::__construct();
		$this->template->set_theme('tpso1');
		$this->template->set_layout('district');
	}
	
	function index(){
		$this->template->set_layout('district_index');
		$this->template->build('district_index');
	}
	
	function info($id){
		$data['info'] = new District_info($id);
		$this->template->build('district_info',$data);
	}
	
	function province($id){
		$data['province'] = new District($id);
		$this->template->build('province',$data);
	}
	
	function inc_menu(){
		$data['province_menus'] = new District();
		$data['province_menus']->where("status = 'approve'")->order_by("id","asc")->get();
		$this->load->view("inc_menu",$data);
	}
	
	function information_list(){
		$data['informations'] = new Information();
		(@$_GET['titlesearch'])?$data['informations']->like('title',$_GET['titlesearch']):'';
		$data['informations']->where("tumbon_show = 'yes'")->order_by("id","desc")->get_page();
		$this->template->build('informations_index',$data);
	}
	
	function info_download($id){
		$info = new District_info($id);
		$info->counter();
		$this->load->helper('download');
		$data = file_get_contents("uploads/info/".basename($info->file));
		$name = basename($info->file);
		force_download($name, $data); 
	}

	function province_download($id){
		$province = new District($id);
		$province->counter();
		$this->load->helper('download');
		$data = file_get_contents("uploads/info/".basename($province->file));
		$name = basename($province->file);
		force_download($name, $data); 
	}
	
	function gallery_list(){
		$data['categories'] = new Category();
		$data['categories']->where("start_date <= date(sysdate()) and (end_date >= date(sysdate()) or end_date = date('0000-00-00')) and module = 'galleries' and parents <> 0 and status = 'approve' and tumbon_show = 'yes'")->order_by('id','desc')->get();
		$this->template->build('gallery_index',$data);
	}

	function vdo_list(){
		$data['vdo_categories'] = new Category();
		$data['vdo_categories']->where("start_date <= date(sysdate()) and (end_date >= date(sysdate()) or end_date = date('0000-00-00')) and module = 'vdos' and parents <> 0 and status = 'approve' and tumbon_show = 'yes'")->order_by("id","desc")->get();
		$this->template->build('vdo_index',$data);
	}
	
	function view($id)
	{
		$data['catagory_id'] = $id;
		$data['galleries'] = new Gallery();
		$data['galleries']->where("category_id = '$id'")->order_by('orderlist','asc')->get_page();
		$this->template->build('gallery_view',$data);
	}
	
	function vdo($id){
		$data['vdos'] = new Vdo();
		$data['vdos']->where("category_id = ".$id)->order_by('id','desc')->get_page();
		$this->template->build('vdo_view',$data);
	}
}
?>